<?php

namespace common\logics\trade;

use Yii;
use common\logics\trade\scope\ShopOrder;
use common\logics\trade\scope\YundOrder;

/**
 * 业务范围对应交易订单模型
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
trait BizOrderModelTrait {

    /**
     * 商城订单
     * @inheritdoc
     */
    protected function shop($id) {
        $model = ShopOrder::findOne([
            'id' => $id,
            'status' => [ShopOrder::STATUS_DEFAULT, ShopOrder::STATUS_ACTIVE],
        ]);
        if ($model && !$model->getIsExpired()) {
            return $model;
        }
        return null;
    }

    /**
     * 悦动圈
     * @return 返回悦动圈交易服务订单模型信息
     * @inheritdoc
     */
    protected function yund($id) {
        //@todo
        //返回悦动圈交易服务订单模型信息
        $query = YundOrder::find();
        $condtion = [];
        $query->andWhere($condtion);
        $model = $query->one();
        if ($model && !$model->getIsExpired()) {
            return $model;
        }
        return null;
    }

}
